package com.kangye.enterprise.frontdesk.service.impl;

import com.alibaba.druid.sql.visitor.functions.If;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kangye.enterprise.frontdesk.entity.Circular;
import com.kangye.enterprise.frontdesk.mapper.CircularMapper;
import com.kangye.enterprise.frontdesk.service.CircularService;
import com.kangye.enterprise.frontdesk.util.ViewJsonObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: enterprise
 * @description: 实现通知表接口
 * @author: 索腾龙
 * @create: 2021-05-27 15:19
 **/
@Service
@Transactional
public class CircularServiceImpl implements CircularService {
    @Autowired
    private CircularMapper circularMapper;
    //查询某地区的全部通知和政策(索腾龙)
    @Override
    public ViewJsonObject<Circular> selCircular(Integer circularSynthesis, String regionName) {
        //调用mapper方法
        List<Circular> list = circularMapper.selCircular(circularSynthesis, regionName);
        if(list.size()>0){
            //返回json格式
            return new ViewJsonObject<>(list);
        }else {
            //失败操作失败
            return new ViewJsonObject<>(1,"操作失败");
        }
    }
    //查询通知和政策的某条详细信息(索腾龙)
    @Override
    public ViewJsonObject<Circular> selCircularById(Integer circularSynthesis, Integer circularId) {
        //用实体类接收方法
        Circular circular = circularMapper.selCircularById(circularSynthesis, circularId);
        //创建list对象
        List<Circular> list = new ArrayList<>();
        //把数据添加到list集合里
        list.add(circular);
        //判断是否有数据
        if (circular!=null){
            return new ViewJsonObject<>(list);
        }else {
            return new ViewJsonObject<>(1, "操作失败");
        }
    }
}